package com.aqiang.day0421.presenter;

import android.util.Log;

import com.alibaba.fastjson.JSON;
import com.aqiang.core.http.HttpCallBack;
import com.aqiang.core.mvp.presenter.BasePresenter;
import com.aqiang.day0421.contarct.TwoContract;
import com.aqiang.day0421.entity.XiaEntity;

import java.util.ArrayList;
import java.util.List;

public class TwoPresenter extends BasePresenter<TwoContract.TwoModel, TwoContract.TwoView> {
    private List<String> stringList;
    public TwoPresenter(TwoContract.TwoModel mModel, TwoContract.TwoView mView) {
        super(mModel, mView);
    }

    public void xia(){
        stringList = new ArrayList<>();
        mModel.requestXia("http://www.qubaobei.com/ios/cf/dish_list.php?stage_id=1&limit=20&page=1", new HttpCallBack() {
            @Override
            public void ok(String json) {
                Log.i("swq", "ok: "+json);
                stringList.add(json);
                XiaEntity xiaEntity = JSON.parseObject(json, XiaEntity.class);
                List<XiaEntity.DataBean> data = xiaEntity.getData();
                mView.initAdapter(data);
            }

            @Override
            public void no(String msg) {
                Log.i("swq", "no: "+msg);
                //吴网络情况
                XiaEntity xiaEntity = JSON.parseObject(stringList.get(0), XiaEntity.class);
                List<XiaEntity.DataBean> data = xiaEntity.getData();
                mView.initAdapter(data);
            }
        });
    }
}
